<?php $this->display('header') ?>
</head>
<body>
<div id="wrapper">
    <!--左侧导航开始-->
    <?php $this->display('menu') ?>
    <!--左侧导航结束-->
    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <?php $this->display('header_top') ?>
        <div class="ibox-content">
            <form class="cmxform form-horizontal tasi-form" id="form_name" name="form_name">
                <div class="form-group  row">
                    <label for="username" class="col-sm-2 col-form-label"> 为<span style="color: red;">{$group['title']}</span>分配权限</label>
                </div>
                <div class="panel-body ">
                    <div class="form">
                        <div class="row cl orm-group">
                            <label class="form-label col-xs-4 col-sm-2">权限列表：</label>
                            <div class="formControls col-xs-8 col-sm-10">
                                {loop $aData $v}
                                <dl class="permission-list">
                                    {if empty($v['_data'])}
                                    <dt>
                                        <label class="i-checks i-checks-sm">
                                            <input type="checkbox"  name="rules_id[]" id="user-Character-0" value="{$v['id']}" {if in_array($v['id'],$group['rules'])} checked {/if}>{$v['title']}
                                        </label>
                                    </dt>
                                    {else}
                                    <dt>
                                        <label class="">
                                            <input type="checkbox" name="rules_id[]"  value="{$v['id']}"  id="user-Character-0" {if in_array($v['id'],$group['rules'])} checked {/if}>{$v['title']}
                                        </label>
                                    </dt>
                                    <dd>
                                        {loop $v['_data'] $n}
                                        <dl class="cl permission-list2">
                                            <dt>
                                                <label class="">
                                                    <input type="checkbox"  name="rules_id[]" value="{$n['id']}" id="user-Character-0-0" {if in_array($n['id'],$group['rules'])} checked {/if}>{$n['title']}
                                                </label>
                                            </dt>
                                            {if $n['_data']}
                                            <dd>
                                                {loop $n['_data']  $c}
                                                <label class="">
                                                    <input type="checkbox" name="rules_id[]"  value="{$c['id']}" id="user-Character-0-0-0" {if in_array($c['id'],$group['rules'])} checked {/if}>{$c['title']}
                                                </label> {/loop}

                                            </dd>
                                            {/if}
                                        </dl>
                                        {/loop}

                                    </dd>
                                    {/if}
                                </dl>
                                {/loop}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group row">
                    <div class="col-sm-2 col-sm-offset-2"></div>
                    <div class="col-sm-4 col-sm-offset-2">
                        <input type="hidden" value="{php echo gWebUrl('auth_group/rule_group_add',['id'=>$group['id']])}" id="url_class" name="url_class">
                        <button class="ladda-button btn btn-info" data-style="slide-right" id="form_submit">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--右侧部分结束-->
</div>

<script>
    //提交表单
    $('#form_submit').click(function() {

        if (!$(this).hasClass('disabled')) {
            $(this).addClass('disabled');
            //验证
            postFormData('form_name');
            setTimeout("$('#form_submit').removeClass('disabled')", 2000);
            return false;
        }
    });

    $(".permission-list dt input:checkbox").click(function(){
        $(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
    });
    $(".permission-list2 dd input:checkbox").click(function(){
        var l =$(this).parent().parent().find("input:checked").length;
        var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
        if($(this).prop("checked")){
            $(this).closest("dl").find("dt input:checkbox").prop("checked",true);
            $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
        }
        else{
            if(l==0){
                $(this).closest("dl").find("dt input:checkbox").prop("checked",false);
            }
            if(l2==0){
                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
            }
        }
    });
</script>
<?php $this->display('foot') ?>